/* SPDX-License-Identifier: GPL-2.0 */
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023. All rights reserved.
 * Author: Huawei OS Kernel Lab
 * Create: Thu Aug 15 16:14:23 2023
 */

#ifndef __ASM_CURRENT_H
#define __ASM_CURRENT_H

#ifndef __ASSEMBLY__

struct task_struct;
int liblinux_thread_setup(void);
extern void *liblinux_thread_get_my_data(void);
static __always_inline struct task_struct *get_current(void)
{
	struct task_struct *p = (struct task_struct *)liblinux_thread_get_my_data();
	if (!p) {
		int ret = liblinux_thread_setup();

		if (ret < 0)
			__builtin_unreachable();
	}
	return (struct task_struct *)liblinux_thread_get_my_data();
}

#define current get_current()

/*
#include <linux/thread_info.h>

#define get_current() (current_thread_info()->task)
#define current get_current()
*/

#endif /* __ASSEMBLY__ */

#endif /* __ASM_CURRENT_H */
